

<%@page import="common.DButil"%>
<%@page import="org.jfree.chart.servlet.ServletUtilities"%>
<%@page import="org.jfree.chart.entity.StandardEntityCollection"%>
<%@page import="org.jfree.chart.entity.EntityCollection"%>
<%@page import="org.jfree.chart.ChartRenderingInfo"%>
<%@page import="org.jfree.chart.JFreeChart"%>
<%@page import="org.jfree.chart.plot.XYPlot"%>
<%@page import="java.awt.Font"%>

<%@page import="org.jfree.chart.axis.NumberAxis"%>
<%@page import="org.jfree.chart.axis.ValueAxis"%>
<%@page import="org.jfree.chart.urls.TimeSeriesURLGenerator"%>
<%@page import="java.text.NumberFormat"%>
<%@page import="org.jfree.chart.urls.StandardXYURLGenerator"%>
<%@page import="org.jfree.chart.urls.StandardXYZURLGenerator"%>
<%@page import="org.jfree.chart.labels.StandardXYSeriesLabelGenerator"%>
<%@page import="org.jfree.chart.renderer.xy.StandardXYItemRenderer"%>
<%@page import="org.jfree.chart.labels.StandardXYItemLabelGenerator"%>
<%@page import="org.jfree.chart.labels.StandardXYToolTipGenerator"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="org.jfree.data.xy.XYSeriesCollection"%>
<%@page import="org.jfree.data.xy.XYSeries"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=GBK" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<% 
 
 DButil db = DButil.getInstance();
	// 借出图书5月
	String sqljc5="select count(*) from reader where r_time>='2014-05-01' AND r_time<'2014-05-31'" ;
	List<String[]> jiechu5 = db.excuteQuery(sqljc5);
	String j=jiechu5.get(0)[0];
	int j5 = Integer.parseInt(j);
	// 借出图书6月
	String sqljc6="select count(*) from reader where r_time>='2014-06-01' AND r_time<'2014-06-30'" ;
	List<String[]> jiechu6 = db.excuteQuery(sqljc6);
	String jj=jiechu6.get(0)[0];
	int j6 = Integer.parseInt(jj);
	// 借出图书7月
	String sqljc7="select count(*) from reader where r_time>='2014-07-01' AND r_time<'2014-07-31'" ;
	List<String[]> jiechu7 = db.excuteQuery(sqljc7);
	String jjj=jiechu7.get(0)[0];
	int j7 = Integer.parseInt(jjj);
 
  XYSeries dataSeries=new XYSeries("增长");

    
   int y=0;
   int x=0;
   dataSeries.add(x, y );
   
   y=j5;
   x=5;
   dataSeries.add(x, y );
   
   y=j6;
   x=6;
   dataSeries.add(x, y );
   
   y=j7;
   x=7;
   dataSeries.add(x, y );
   
   
   XYSeriesCollection xyDataset=new XYSeriesCollection();
   xyDataset.addSeries(dataSeries);
    
    
    String filename="";
    SimpleDateFormat sdf=new SimpleDateFormat("dd-MMM-yyyy",Locale.UK);
    StandardXYToolTipGenerator ttg=new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,sdf,NumberFormat.getInstance());
    TimeSeriesURLGenerator urlg=new TimeSeriesURLGenerator(sdf,"zhexiantu.jsp","series","hitDate");
    
     ValueAxis xAxis=new NumberAxis("X坐标");
     ValueAxis yAxis=new NumberAxis("Y坐标");
     
     StandardXYItemRenderer renderer=new StandardXYItemRenderer(StandardXYItemRenderer.LINES,ttg,urlg);
     renderer.setShapesFilled(true);
     Font font=new Font("黑体",Font.TRUETYPE_FONT,12);
     XYPlot plot=new XYPlot(xyDataset,xAxis,yAxis,renderer);
     JFreeChart chart=new JFreeChart("读者数",font,plot,true);
     ChartRenderingInfo info=new ChartRenderingInfo(new StandardEntityCollection());
     filename=ServletUtilities.saveChartAsPNG(chart, 700, 500, info, session);
     String graphURL=request.getContextPath()+"/DisplayChart?filename="+filename;
     
 %>
<html>

  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'zhexiantu.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>

<img  src="<%= graphURL %>" width="700" height="500" border="0" usemap="#<%=filename%>"/>


  </body>
</html>
